package com.ruoyi.project.channel.businessInfoOrder.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.channel.businessInfoOrder.domain.BusinessInfoOrder;
import com.ruoyi.project.channel.businessInfoOrder.service.IBusinessInfoOrderService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 会员卡单信息操作处理
 * 
 * @author CAIN
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/channel/businessInfoOrder")
public class BusinessInfoOrderController extends BaseController
{
    private String prefix = "channel/businessInfoOrder";
	
	@Autowired
	private IBusinessInfoOrderService businessInfoOrderService;
	
	@RequiresPermissions("channel:businessInfoOrder:view")
	@GetMapping()
	public String businessInfoOrder()
	{
	    return prefix + "/businessInfoOrder";
	}
	
	/**
	 * 查询会员卡单列表
	 */
	@RequiresPermissions("channel:businessInfoOrder:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BusinessInfoOrder businessInfoOrder)
	{
		startPage();
        List<BusinessInfoOrder> list = businessInfoOrderService.selectBusinessInfoOrderList(businessInfoOrder);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出会员卡单列表
	 */
	@RequiresPermissions("channel:businessInfoOrder:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BusinessInfoOrder businessInfoOrder)
    {
    	List<BusinessInfoOrder> list = businessInfoOrderService.selectBusinessInfoOrderList(businessInfoOrder);
        ExcelUtil<BusinessInfoOrder> util = new ExcelUtil<BusinessInfoOrder>(BusinessInfoOrder.class);
        return util.exportExcel(list, "businessInfoOrder");
    }
	
	/**
	 * 新增会员卡单
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存会员卡单
	 */
	@RequiresPermissions("channel:businessInfoOrder:add")
	@Log(title = "会员卡单", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BusinessInfoOrder businessInfoOrder)
	{		
		return toAjax(businessInfoOrderService.insertBusinessInfoOrder(businessInfoOrder));
	}

	/**
	 * 修改会员卡单
	 */
	@GetMapping("/edit/{userId}")
	public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
	{
		BusinessInfoOrder businessInfoOrder = businessInfoOrderService.selectBusinessInfoOrderById(userId);
		mmap.put("businessInfoOrder", businessInfoOrder);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存会员卡单
	 */
	@RequiresPermissions("channel:businessInfoOrder:edit")
	@Log(title = "会员卡单", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BusinessInfoOrder businessInfoOrder)
	{		
		return toAjax(businessInfoOrderService.updateBusinessInfoOrder(businessInfoOrder));
	}
	
	/**
	 * 删除会员卡单
	 */
	@RequiresPermissions("channel:businessInfoOrder:remove")
	@Log(title = "会员卡单", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(businessInfoOrderService.deleteBusinessInfoOrderByIds(ids));
	}
	
}
